package org.dromara.system.mapper;

import org.apache.ibatis.annotations.Param;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.system.domain.Device;
import org.dromara.system.domain.VariableAssociation;
import org.dromara.system.domain.VariableAssociationParam;
import org.dromara.system.domain.pojo.TunnelStats;
import org.dromara.system.domain.vo.*;

import java.util.Collection;
import java.util.List;

/**
 * 设备信息Mapper接口
 *
 * @author Lion Li
 * @date 2024-10-21
 */
public interface DeviceMapper extends BaseMapperPlus<Device, DeviceVo> {

    DeviceInfoVo getDeviceInfoById(Long id);

    List<VariableAssociationDescVo> selectVariableAssociationList(Long id);

    List<VariableAssociationParam> selectVariableAssociationParams(Long id);

    int setVariableAssociation(@Param("deviceId") Long deviceId, @Param("ids") Collection<Long> ids);

    int deleteVariableAssociation(@Param("deviceId") Long deviceId);

    int unbindVariableAssociation(@Param("deviceId") Long deviceId, @Param("id") Long id);

    int bindDeviceVariable(@Param("deviceId") Long deviceId, @Param("id") Long id);

    List<NameVo> getDeviceVariableValueList(Long id);

    Integer selectTotalCount();

    List<StatisticsDeviceVo> statisticsDeviceVo();

    List<Long> selectGroupIdsWithDevices();

    String selectNameById(@Param("id") Long deviceId);

    void updateStatusIfLastPingExceeds30Minutes();

    void updateVariableStatusIfLastPingExceeds30Minutes();

    List<Long> getAllDevicesIds();

    int countNonZeroStatusVariables(@Param("deviceId") Long deviceId);

    void updateDeviceStatusToZero(@Param("deviceId") Long deviceId);

    TunnelStats selectReverseAndForwardCount(@Param("tunnelId") Long TunnelId, @Param("groupIds") Collection<Long> groupIds);

    List<Long> findAllSubNodeIds(@Param("source") Long source);

    Long selectFaultCount(@Param("tunnelId") Long tunnelId, @Param("groupIds") List<Long> allSubNodeIds);
}
